import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import './utils/rem'
import './assets/stylesheets/reset.css'
import './assets/font-awesome-4.7.0/font-awesome-4.7.0/css/font-awesome.min.css'

import { BrowserRouter as Router } from 'react-router-dom'
import store from './store'
import { Provider  } from 'react-redux'



import 'swiper/dist/css/swiper.min.css'


// 添加axios 拦截器（ 为了loading效果 ）

import { Toast } from 'antd-mobile';

import axios from 'axios'

// import { Indicator } from 'mint-ui'
// Add a request interceptor
  axios.interceptors.request.use(function (config) {
    // Do something before request is sent

    //请求发送前  loading是开启的

    // Indicator.open({
    //   text: '加载中。。。',
    //   spinnerType: 'fading-circle'
    // });
   
    Toast.loading('Loading...',1, () => {
       
      });
    return config;
  }, function (error) {
    
    // 请求到数据之后，关闭loading


    return Promise.reject(error);
  });

  // Add a response interceptor
  axios.interceptors.response.use(function (response) {
    // Do something with response data

    // Indicator.close()
    // console.log(2)
    // Toast.hide()

    return response;
  }, function (error) {
    // Do something with response error
    return Promise.reject(error);
  });



ReactDOM.render(
    <Provider store={ store }>
    <Router>
        <App />
    </Router>
    </Provider>
, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
